#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>



int main()
{

	int sock = 0;
	int ret = 0;
	char buf[1024] = {0};

	struct sockaddr_in serAddr;
    memset(&serAddr,0,sizeof(serAddr));

	sock = socket(AF_INET,SOCK_STREAM,0);
	if(sock == -1)
	{
		perror("sock");
		exit(-1);
	}

	serAddr.sin_family = AF_INET;
    serAddr.sin_port = htons(6868);
    serAddr.sin_addr.s_addr = inet_addr("192.168.0.181");

	ret = connect(sock,(struct sockaddr *)&serAddr,sizeof(struct sockaddr));
	if(ret == -1)
	{
		perror("connect");
		exit(-1);
	}

	char dest[1024] = {0};

 while(1)
 {
	 printf("please input a string:\n");
	 scanf("%s",dest);
	ret = send(sock,dest,strlen(dest),0);
	if(ret == -1)
	{
		perror("send");
	}
	ret = recv(sock,buf,sizeof(buf) - 1,0);
	if(ret == -1)
	{
		perror("recv");
		exit(-1);
	}

	printf("buf is %s\n",buf);
 }

	close(sock);

}

